package week.six;

import java.nio.*;

import javax.microedition.khronos.opengles.GL10;

public class Square {

	private FloatBuffer vertexBuffer;
	
	private float vertices[] = {
		0.0f, 200.0f, 0.0f,
		200.0f, 200.0f, 0.0f,
		0.0f, 0.0f, 0.0f,
		200.0f, 0.0f, 0.0f
	};
	
	public Square() {
		ByteBuffer bytebuf = ByteBuffer.allocateDirect(vertices.length * 4);
		bytebuf.order(ByteOrder.nativeOrder());
		vertexBuffer = bytebuf.asFloatBuffer();
		vertexBuffer.put(vertices);
		vertexBuffer.position(0);
	}
	
	public void draw(GL10 gl) {
		gl.glFrontFace(GL10.GL_CW);
		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
	}
}
